package com.example.byteinputstream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class ByteStreamDemo1 {
    public static void main(String[] args) throws IOException {

        /**
         * 字节输入流: FileInputStream
         * 文件向程序输入数据
         */

        //创建对象
        FileInputStream fis = new FileInputStream("src/com/example/file/a.txt");

        //读取数据
        int read1 = fis.read();
        System.out.println((char) read1);

        int read2 = fis.read();
        System.out.println((char) read2);

        int read3 = fis.read();
        System.out.println((char) read3);

        int read4 = fis.read();
        System.out.println((char) read4);

        int read5 = fis.read();
        System.out.println((char) read5);

        int read6 = fis.read();
        System.out.println(read6);// -1

        //释放资源
        fis.close();

    }
}
